package com.jhws.business.comm.controller;

import com.jhws.common.base.bo.JsonRespData;
import com.jhws.business.comm.bo.RoomType;
import com.jhws.business.comm.service.RoomTypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;


@Controller
@RequestMapping("/RoomTypeCtrl")
public class RoomTypeCtrl {
    @Resource
    private RoomTypeService roomTypeService;

    /**
     * 保存户型信息
     *
     * @param roomType 户型信息
     */
    @RequestMapping("saveRoomType.x")
    @ResponseBody
    public JsonRespData saveRoomType(RoomType roomType) throws Exception {
        roomTypeService.saveRoomType(roomType);
        return new JsonRespData("", 1, "保存成功");
    }

    /**
     * 查询户型信息
     *
     * @param id 户型信息ID
     */
    @RequestMapping("queryRoomType.x")
    @ResponseBody
    public JsonRespData queryRoomType(long id) {
        return new JsonRespData("", 1, roomTypeService.queryRoomType(id));
    }

    /**
     * 条件查询户型信息列表
     */
    @RequestMapping("queryRoomTypes.x")
    @ResponseBody
    public JsonRespData queryRoomTypes(String commCode) {
        String where = "where 1=1 and comm_code='" + commCode + "'";
        return new JsonRespData("", 1, roomTypeService.queryRoomTypes(where));
    }

    /**
     * 分页查询户型信息列表
     *
     * @param param 条件
     */
    @RequestMapping("queryRoomTypePage.x")
    @ResponseBody
    public JsonRespData queryRoomTypePage(@RequestParam Map param) {
        return new JsonRespData("", 1, roomTypeService.queryRoomTypePage(param));
    }

    /**
     * 删除户型信息
     *
     * @param roomType 户型信息ID
     */
    @RequestMapping("deleteRoomType.x")
    @ResponseBody
    public JsonRespData deleteRoomType(RoomType roomType) {
        roomTypeService.deleteRoomType(roomType);
        return new JsonRespData("", 1, "删除成功");
    }
}
